package luj.game.robot.internal.dynamic.combine;

import com.google.common.collect.ImmutableList;
import luj.bean.api.BeanContext;
import luj.game.robot.api.action.RobotBossCommand;
import luj.game.robot.api.action.RobotCreateListener;
import luj.game.robot.api.action.RobotDataCommand;
import luj.game.robot.api.boot.RobotStartListener;
import luj.game.robot.api.network.RobotProtoHandler;
import luj.game.robot.internal.dynamic.init.DynamicInitInvoker;
import luj.game.robot.internal.session.inject.StaticBeanCollector;
import luj.game.robot.internal.session.inject.botinstance.RobotInstanceInjectRoot;

import java.util.List;

final class ResultImpl implements AllBeanCombiner.Result {

  @Override
  public List<RobotStartListener> startListener() {
    return ImmutableList.<RobotStartListener>builder()
        .addAll(_staticRoot.startListener())
        .addAll(_dynamicRoot.startListener())
        .build();
  }

  @Override
  public List<RobotCreateListener> createListener() {
    return ImmutableList.<RobotCreateListener>builder()
        .addAll(_staticRoot.instanceRoot().getCreateListener())
        .addAll(_dynamicRoot.createListener())
        .build();
  }

  @Override
  public List<RobotBossCommand<?>> bossCommand() {
    return ImmutableList.<RobotBossCommand<?>>builder()
//        .addAll(_staticRoot.dataCommand())
        .addAll(_dynamicRoot.bossCommand())
        .build();
  }

  @Override
  public List<RobotDataCommand<?>> workerCommand() {
    return ImmutableList.<RobotDataCommand<?>>builder()
        .addAll(_staticRoot.dataCommand())
        .addAll(_dynamicRoot.dataCommand())
        .build();
  }

  @Override
  public List<RobotProtoHandler<?>> protoHandler() {
    return ImmutableList.<RobotProtoHandler<?>>builder()
        .addAll(_staticRoot.protoHandler())
        .addAll(_dynamicRoot.protoHandler())
        .build();
  }

  @Override
  public AllBeanCombiner.Http http() {
    var http = new RHttpImpl();
    http._staticRoot = _staticRoot;
    http._dynamicRoot = _dynamicRoot;

    return http;
  }

  @Override
  public RobotInstanceInjectRoot instanceRoot() {
    return _staticRoot.instanceRoot();
  }

  @Override
  public BeanContext lujbean() {
    return _lujbean;
  }

  StaticBeanCollector.Result _staticRoot;
  DynamicInitInvoker.Result _dynamicRoot;

  BeanContext _lujbean;
}
